home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / ATMInterface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-05  |  3.8 KB  |  109 lines  |  [TEXT/MMCC]

  1. /*
  2.  * ATMInterface.c
  3.  *
  4.  * Version 1.01
  5.  *
  6.  * Adobe Type Manager is a trademark 
  7.  * of Adobe Systems Incorporated.
  8.  
  9. As provided by Adobe, ATMInterface.c only worked if compiled as 68k code. I've
  10. enhanced it, by changing the direct calls to ATM to indirect CallUniversalProc
  11. calls, so the Mixed Mode Manager can do its magic if this file is compiled to
  12. run native. This works with the current 68k version of ATM (3.6.1), and will
  13. probably also work with the forthcoming fat version of ATM (3.8?), assuming
  14. Adobe maintains the API (Application Programming Interface). However, we will be
  15. calling the 68k code in ATM.
  16.  
  17. This program from Adobe (Version 1.01) is quite old, but its API is still
  18. supported by current versions of ATM (3.6.1). The newer versions add a way to return
  19. an error code to some of these functions, and add a whole slew of functions
  20. for controlling SuperATM's Multiple font Master capabilities.
  21. The current version (3.0) of ATMInterface.c can be downloaded from:
  22. ftp://ftp.mv.us.adobe.com/pub/adobe/Programs/MacATM30headers.sea.hqx
  23. For current documentation of the ATM Macintosh C interface download:
  24. ftp://ftp.mv.us.adobe.com/pub/adobe/DeveloperSupport/TechNotes/5072.ATM_Adv_Mac.pdf
  25.  
  26. HISTORY:
  27. 93?    dgp I don't remember how or when I got this. Perhaps from the Adobe section 
  28. of Compuserve.
  29. 9/7/94 dgp Introduced Universal proc pointers to allow PowerPC code to call
  30. the current (68k) version of ATM (3.6.1). 
  31. 11/15/94 dgp made compatible with pre-Universal headers.
  32. 1/5/95 dgp made compatible with Universal Headers 2.
  33. */
  34. #include "ATMInterface.h"
  35. #if __powerc
  36.     #include <MixedMode.h>
  37.     enum{
  38.         uppFontAvailable=kThinkCStackBased
  39.             | RESULT_SIZE(kTwoByteCode)
  40.             | STACK_ROUTINE_PARAMETER(1,kTwoByteCode)
  41.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  42.         ,uppShowText=kThinkCStackBased
  43.             | RESULT_SIZE(kTwoByteCode)
  44.             | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
  45.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  46.             | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
  47.         ,uppXyshowText=kThinkCStackBased
  48.             | RESULT_SIZE(kTwoByteCode)
  49.             | STACK_ROUTINE_PARAMETER(1,kFourByteCode)
  50.             | STACK_ROUTINE_PARAMETER(2,kTwoByteCode)
  51.             | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
  52.             | STACK_ROUTINE_PARAMETER(4,kFourByteCode)
  53.     };
  54. #elif !defined(NewRoutineDescriptor)
  55.     #define NewRoutineDescriptor(theProc, theProcInfo, theISA) (theProc)
  56. #endif
  57.  
  58.  
  59. static short open=0;
  60. static ATMProcs3 procs;
  61.  
  62. short initATM(void)
  63. {
  64.     CntrlParam c;
  65.     
  66.     if(open)return 1;    // added by Denis Pelli to skip opening if already open
  67.     if(OpenDriver("\p.ATM",&c.ioCRefNum))return 0;
  68.     c.csCode = ATMProcsStatusCode;
  69.     *(ATMProcs3 **) c.csParam = &procs;
  70.     procs.version = ATMProcs3Version;
  71.     if(PBStatus((ParmBlkPtr)&c,0))return 0;
  72.     open=1;
  73.     /* replace each ProcPtr by a UniversalProcPtr. */
  74.     procs.fontAvailable=(void *)NewRoutineDescriptor((ProcPtr)procs.fontAvailable,uppFontAvailable,kM68kISA);
  75.     procs.showText=(void *)NewRoutineDescriptor((ProcPtr)procs.showText,uppShowText,kM68kISA);
  76.     procs.xyshowText=(void *)NewRoutineDescriptor((ProcPtr)procs.xyshowText,uppXyshowText,kM68kISA);
  77.     return 1;
  78. }
  79.  
  80. short fontAvailableATM(short family,short style)
  81. {
  82.     #if !defined(__powerc)
  83.         return open ? (*procs.fontAvailable)(family,style) : 0;
  84.     #else
  85.         return open ? CallUniversalProc(procs.fontAvailable,uppFontAvailable
  86.             ,family,style) : 0;
  87.     #endif
  88. }
  89.  
  90. short showTextATM(char *text,short length,FixedMatrix *matrix)
  91. {
  92.     #if !defined(__powerc)
  93.         return open ? (*procs.showText)(text,length,matrix) : length;
  94.     #else
  95.         return open ? CallUniversalProc(procs.showText,uppShowText
  96.             ,text,length,matrix) : length;
  97.     #endif
  98. }
  99.  
  100. short xyshowTextATM(char *text,short length,FixedMatrix *matrix,Fixed *displacements)
  101. {
  102.     #if !defined(__powerc)
  103.         return open ? (*procs.xyshowText)(text,length,matrix,displacements) : length;
  104.     #else
  105.         return open ? CallUniversalProc(procs.xyshowText,uppXyshowText
  106.             ,text,length,matrix,displacements) : length;
  107.     #endif
  108. }
  109.